﻿using System;
using System.Collections.Generic;
using AndrewSiemer.KnowledgeExchange.DataAccess;
using NUnit.Framework;
using Rhino.Mocks;

namespace AndrewSiemer.KnowledgeExchange.Core.Tests
{
    [TestFixture]
    public class PostServiceTests
    {
        [Test]
        public void GetsAllPosts_GetsPosts()
        {
            MockRepository mocks = new MockRepository();

            List<Domain.Post> posts = new List<Domain.Post>();
            for (int i = 0; i < 10; i++) { posts.Add(new Domain.Post() { Body = "Post Body", CreateDate = DateTime.Now, LastUpdated = DateTime.Now, PostID = i + 1, ProfileID = 1, Title = "Post Title" }); }
            
            IPostRepository _postRepository = mocks.StrictMock<IPostRepository>();
            Expect.Call(_postRepository.GetAllPosts()).Return(posts);

            IPostService _postService = new PostService(_postRepository);
            mocks.ReplayAll();

            List<Domain.Post> testResult = _postService.GetAllPosts();
            Assert.IsNotEmpty(testResult);
        }
    }
}